package ModelLayer;
import java.util.ArrayList;

public class Item
{
    //instance variables
    private String id;
    private String name;
    private ArrayList<SalesLine> salesLine;
    private double price;
    private Discount discount;
    
    /**
     * Empty constructor for testing purposes
     */
    
    public Item()
    {
        id = "";
        name = "";
        salesLine = new ArrayList<SalesLine>();
        price = 0.0;
        discount = new Discount();
    }
    
    /**
     * Constructor for object of class Order
     */
    
    public Item(String _id, String _name, ArrayList<SalesLine> _salesLine, Discount _discount)
    {
       id = _id;
       name = _name;
       salesLine = _salesLine;
       discount = _discount;
    }
    
    /**
     * Accessor and Mutator methods
     */
    
    public void setId(String _id)
    {
        id = _id;
    }
    
    public String getId()
    {
        return id;
    }
    
    public void setName(String _name)
    {
        name = _name;
    }
    
    public String getName()
    {
        return name;
    }
    
    public void setSalesLine(SalesLine _salesLine)
    {
        salesLine.add(_salesLine);
    }
    
    public SalesLine getSalesLine(int _productId)
    {
        SalesLine sl = new SalesLine();
        for(int i = 0; i<salesLine.size(); i++)  
        {
            if (salesLine.get(i).getId().equals(_productId))
                sl = salesLine.get(i);
        }
        return sl;
    }
    
    public void setPrice(double _price)
    {
        price = _price;
    }
    
    public double getPrice()
    {
        return price;
    }
    
    public void setDiscount(Discount _discount)
    {
        discount = _discount;
    }
    
    public Discount getDiscount()
    {
        return discount;
    }
    
}
